// 获取URL参数的函数
function getParameterByName(name) {
    name = name.replace(/[\$ ]/, '\\[').replace(/[\ $]/, '\\]');
    var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
    var results = regex.exec(location.search);
    return results === null ? '' : decodeURIComponent(results[1].replace(/\\+/g, ' '));
}
var lang = getParameterByName('lang');
var result = getParameterByName('result');
$(".result").text(result)
if (lang == 0 ) {
    $(".href").text('打开SolarUnit应用')
    console.log("当前系统语言是中文");
} else if (lang == 1 ) {
    $(".href").text('Open the solarunit application')
    console.log("当前系统语言是英语");
}else if (lang == 2 ) {
    $(".href").text('Otevřete aplikaci Solarunit')
    console.log("当前系统语言是捷克");
}else if (lang == 3 ) {
    $(".href").text('Öffnen Sie die Solarunit -Anwendung')
    console.log("当前系统语言是德语");
}else if (lang == 4 ) {
    $(".href").text('Abra o aplicativo SolarUnit')
    console.log("当前系统语言是葡萄牙语");
}else if (lang == 5 ) {
    $(".href").text("Apri l'applicazione SolarUnit")
    console.log("当前系统语言是意大利语");
}else if (lang == 6 ) {
    $(".href").text('Откройте приложение Solarunit')
    console.log("当前系统语言是俄语");
}else if (lang == 7 ) {
    $(".href").text('Abra la aplicación SolarUnit')
    console.log("当前系统语言是西班牙语");
}else{
    $(".href").text('Open the solarunit application')
}
    function detectOS() {
        const ua = navigator.userAgent || navigator.vendor || window.opera;
    
        // 检查 iOS 设备
        if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) {
        return 'iOS';
        }
    
        // 检查 Android 设备
        if (/Android/.test(ua) || /Adr/.test(ua)) {
        return 'Android';
        }
    
        // 默认情况
        return 'unknown';
    }
    function openSolarUnit() {
        if (detectOS()=='iOS') {
            window.location.href = "https://apps.apple.com/us/app/solarunit/id6444245984";
        } else {
            window.location.href = "solarunit://";
        }
    }